﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Core;

namespace DAL
{
    public class ReActivityDAL : SyncBase<Model.ReActivity>
    {
        static ReActivityDAL()
        {
            StringBuilder strSql = new StringBuilder();
            ReActivityDAL.addSQL = @"insert into TempReActivity(
                                    TeacherID,LessionID,ActivityBatch,ActivityTime,ActivityPiont,IsEnd,RecordTime)
                                     values (
                                    @TeacherID,@LessionID,@ActivityBatch,@ActivityTime,@ActivityPiont,@IsEnd,@RecordTime)";
            ReActivityDAL.tbName = "TempReActivity";
            ReActivityDAL.remoteUrl = "/Ayyfford/AddReActivity";
            ReActivityDAL.setVal = (lt) =>
            {
                StringBuilder sb = new StringBuilder();
                string _ids = string.Empty;
                if (lt != null && lt.Count > 0)
                {
                    lt.ForEach(t =>
                    {
                        _ids += t.ID + ",";
                        sb.AppendFormat("({0}, {1}, {2}, {3}, {4}, {5}, {6}),",
                            t.TeacherID.NullNumber(), t.LessionID.NullNumber(), t.ActivityBatch.NullNumber(), t.ActivityTime.NullDate(), t.ActivityPiont.NullNumber(), t.IsEnd ? 1 : 0, t.RecordTime.NullDate());
                    });
                }
                return new Tuple<string, string>(sb.ToString(), _ids);
            };
        }

        new public static void SaveEntity(Model.ReActivity t)
        {
            SyncBase<Model.ReActivity>.SaveEntity(t);
        }

        new public static void AsyncData()
        {
            SyncBase<Model.ReActivity>.AsyncData();
        }
    }
}
